package Servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import anonymus.excepcion.DAOExcepcion;
import anonymus.negocio.EventoNegocio;

/**
 * Servlet implementation class RegistroEventoServlet
 */
@WebServlet("/RegistroEventoServlet")
public class RegistroEventoServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public RegistroEventoServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		EventoNegocio neg = new EventoNegocio();
		
		int local = Integer.parseInt(request.getParameter("cboNombreLocal"));
		
		String nombreEvento = request.getParameter("txtNombreEvento");
		String premio = request.getParameter("txtPremio");
		int cantidad = Integer.parseInt(request.getParameter("txtCantidad"));
		String FechaLimite = request.getParameter("txtDia");
		String FechaInicio = request.getParameter("txtDiaInicio");
		String FechaFin = request.getParameter("txtDiaFin");
		
		
			
			 System.out.println("Grabado Satisfactoriamente");
             try {
                     neg.insertarEvento(nombreEvento, premio, cantidad, FechaLimite, FechaInicio, FechaFin, local);
//                   neg.insertarLocalServicio(local,codServicio);
                     response.sendRedirect(request.getContextPath() + "/Local.jsp");
                     
                     
             } catch (DAOExcepcion e) {
                     // TODO Auto-generated catch block
                     e.printStackTrace();
		
             }
	}
}
